<template>
  <div>
    <div>
      <el-button v-if="isCollapse" size="mini" icon="el-icon-d-arrow-right" @click="collapseHandler"></el-button>
      <el-button v-else size="mini" icon="el-icon-d-arrow-left" @click="collapseHandler"></el-button>
    </div>
    <el-menu :collapse="isCollapse"
             background-color="#545c64"
             text-color="#fff"
             class="el-menu-vertical-demo"
             active-text-color="#ffd04b">
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-bell"></i>
          <span slot="title">导航1</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="1-1">
            导航1-1
          </el-menu-item>
          <el-menu-item index="1-2">
            导航1-2
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title">
          <i class="el-icon-search"></i>
          <span slot="title">导航2</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="2-1">
            导航2-1
          </el-menu-item>
          <el-menu-item index="2-2">
            导航2-2
          </el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        name: "MenuTest",
        isCollapse: {
          type: Boolean,
          default: true
        }
      }
    },
    methods: {
      collapseHandler() {
        this.isCollapse = this.isCollapse ? false : true;
      }
    }
  }
</script>

<style scoped>
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 100%;
    min-height: 400px;
  }
</style>
